using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using WLYT.Admin.WebApi.Models;
using WLYT.Application.Interfaces;
using WLYT.Domain.Model;

namespace WLYT.Admin.WebApi.Controllers
{
    [System.Web.Http.Description.ApiExplorerSettings(IgnoreApi = true)]
    public class InventoryController : BaseController
    {
        private readonly IInventoryService InventoryService;

        public InventoryController(IInventoryService _nameService)
        {
            InventoryService = _nameService;
        }

        [HttpGet]
        [Route("api/Inventory/GetData")]
        public async Task<Table<Inventory>> GetData(string itemCode, string labelId, string originalCode, int? minQty, int? maxQty, string location, string wareCode, int? status, int pageSize, int pageIndex)
        {
            var response = await InventoryService.GetModelsByPageAsync(itemCode, labelId, originalCode, minQty, maxQty, location, wareCode, status, pageSize, pageIndex);
            return new Table<Inventory>(response.Item1, response.Item2);
        }
        
        [HttpGet]
        [Route("api/Inventory/GetMaterials")]
        public async Task<Table<object>> GetMaterials(string itemCode, string wareCode, int pageSize, int pageIndex)
        {
            var response = await InventoryService.GetMaterialsByPageAsync(itemCode, wareCode, pageSize, pageIndex);
            return new Table<object>(response.Item1, response.Item2);
        }
    }
}